package com.gi.profiler.providers;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.gi.profiler.utils.DataConstants;

public class IconsAdapter extends BaseAdapter {

    private Context context;
    private Integer[] data = DataConstants.ICONS_ARRAY;

    public IconsAdapter(Context context) {
	this.context = context;
    }

    public int getCount() {
	return data.length;
    }

    public Object getItem(int position) {
	return null;
    }

    public long getItemId(int position) {
	return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
	ImageView imageView;
	if (convertView == null) { // if it's not recycled, initialize some
				   // attributes
	    imageView = new ImageView(context);
	    imageView.setLayoutParams(new GridView.LayoutParams(46, 46));
	    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
	    imageView.setPadding(8, 8, 8, 8);
	} else {
	    imageView = (ImageView) convertView;
	}

	imageView.setImageResource(data[position]);
	return imageView;
    }
}
